import { create } from 'zustand';
import { devtools } from 'zustand/middleware';

// 导入各个store
export { useAccountStore } from './accountStore';
export { useCompetitorStore } from './competitorStore';
export { useMaterialStore } from './materialStore';
export { useDraftStore } from './draftStore';
export { usePublishStore } from './publishStore';
export { useSettingStore } from './settingStore';

// 全局状态类型
export interface GlobalState {
  // 全局加载状态
  loading: boolean;
  setLoading: (loading: boolean) => void;
  
  // 全局错误状态
  error: string | null;
  setError: (error: string | null) => void;
  
  // 全局通知
  notification: {
    type: 'success' | 'error' | 'warning' | 'info';
    message: string;
    description?: string;
  } | null;
  setNotification: (notification: GlobalState['notification']) => void;
  
  // 文件存储路径
  storagePath: string;
  setStoragePath: (path: string) => void;
}

// 创建全局状态store
export const useGlobalStore = create<GlobalState>()(
  devtools(
    (set) => ({
      loading: false,
      setLoading: (loading) => set({ loading }),
      
      error: null,
      setError: (error) => set({ error }),
      
      notification: null,
      setNotification: (notification) => set({ notification }),
      
      storagePath: '',
      setStoragePath: (storagePath) => set({ storagePath }),
    }),
    {
      name: 'global-store',
    }
  )
); 